﻿using System;
using System.Threading;

namespace FrameWork.Core.ThreadPool
{
    public class TaskQueueItem
    {
        /// <summary>
        /// 分组编号
        /// </summary>
        public int GroupID { get; set; }
        /// <summary>
        /// ID
        /// </summary>
        public int ID { get; set; } = 0;
        /// <summary>
        /// 任务名称
        /// </summary>
        public string Name { get; set; } = string.Empty;
        /// <summary>
        /// 任务
        /// </summary>
        public Func<bool> Func { get; set; }
        /// <summary>
        /// 任务
        /// </summary>
        public Action Action { get; set; }
        /// <summary>
        /// 是否重复执行
        /// </summary>
        public bool ReExecute { get; set; } = false;
        /// <summary>
        /// 最大重复次数
        /// 小于等于0表示不限制
        /// </summary>
        public int ReCount { get; set; } = 0;
        /// <summary>
        /// 已经执行的次数
        /// </summary>
        public int ExecCount { get; set; } = 0;
        /// <summary>
        /// 取消锁
        /// </summary>
        public CancellationTokenSource Cts { get; set; }

        public TaskQueueItem() { }

        public TaskQueueItem(Func<bool> func)
        {
            this.Func = func;
        }
        public TaskQueueItem(Action action)
        {
            this.Action = action;
        }
    }
}
